﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace project_phoebus.CruiseCompany
{
    class Program
    {
        static void Main(string[] args)
        {

#if true
            using (MainModelContainer context = new MainModelContainer())
            {
            
                Manager find;

                for(int i=0; i<10; i++)
                {
                    Console.Write("login :\t");
                    string login = Console.ReadLine();

                    Console.Write("pass :\t");
                    string pass = Console.ReadLine();

                    find = context.Managers.FirstOrDefault(manager=>manager.Login == login);

                    if (find != null)
                    {
                        Console.WriteLine(Engine.Compare(pass, find.Password, find.Salt));
                    }
                    else Console.WriteLine("!error!\n");

                }
            }

#elif false
            using (MainModelContainer context = new MainModelContainer())
            {
                for (int i = 1; i <= 10; i++)
                {
                    string tmp = "user" + i.ToString();
                    string salt = Engine.GenerateSalt();
                    string pass = Engine.Crypted(tmp, salt);
                    Manager foo = new Manager
                    {
                        Login = "User" + i.ToString(),
                        Salt = salt,
                        Password = pass,
                        Role = "manager",
                        FName = "FName",
                        SName = "SName",
                        BDate = new DateTime(1989 + i, i, i),
                        Email = "mail@server.com",
                        Phone = "555-555"
                    };

                    context.Managers.AddObject(foo);
                    context.SaveChanges();

                    Console.WriteLine(".");
                    Console.ReadKey();
                }
             //  context.SaveChanges();
            }


#elif false

            string temp = Engine.GetMd5Hash("Three can keep a secret, if two of them are dead.");

            Console.WriteLine(temp);

#elif false

           // Console.WriteLine(Engine.Hash());

            for (int i = 0; i < 100; i++)
            {
                temp = Engine.GenerateSalt();
                Console.WriteLine(temp);
                Console.ReadKey();
            }

#else 
            using (MainModelContainer context = new MainModelContainer())
            {
                Customer t = new Customer
                {
                    FName = "Петечка",
                    SName = "Неймспейсов",
                    CurrentAccount = "12131414",
                    PassportSeries = "АР",
                    PassportNumber = 123111
                };
                context.Customers.AddObject(t);
                Console.WriteLine("Records... {0}" + context.Customers.Count());
            }
#endif
            Console.Read();
        }
    }
}
